<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link
      rel="stylesheet"
      href="/node_modules/bootstrap/dist/css/bootstrap.css"
    />
    <link rel="stylesheet" href="/public/css/login.css" />
    <title>Document</title>
  </head>
  <body>
    <div class="main">
      <div class="header">
        <a href="/">
          <img width="80" height="80" src="../public/img/logo.png" alt="" />
        </a>
        <p>Sign in to blog</p>
      </div>
      <form id="login_form" action="">
        <div class="form-group">
          <label for="email">邮箱</label>
          <input
            class="form-control"
            type="email"
            name="email"
            id="email"
            placeholder="Email"
            autofocus
          />
        </div>
        <div class="form-group">
          <label for="password">密码</label>
          <a style="float: right" href="/show">忘记密码?</a>
          <input
            class="form-control"
            type="password"
            name="password"
            id="password"
            placeholder="Password"
          />
        </div>

        <button type="submit" class="btn btn-success btn-block">登录</button>
      </form>
      <div class="message">
        <p>没有账号？</p>
        <a href="/register">点击创建.</a>
      </div>
    </div>
    <div class="footer">{{ include './_partial/footer.html' }}</div>
    <script src="/node_modules/jquery/dist/jquery.js"></script>
    <script src="/node_modules/bootstrap/dist/js/bootstrap.js"></script>
    {{ if code }}
    <script>
      alert('注册成功，请登录')
    </script>
    {{ /if }}
    <script>
      $('#login_form').on('submit', function (e) {
        e.preventDefault()
        //表单序列化
        let formData = $(this).serialize()
        $.ajax({
          url: '/register',
          type: 'post',
          data: formData,
          dataType: 'json',
          success: function (data) {},
        })
      })
    </script>
  </body>
</html>
